/**
 * test
 */
require(["jquery","bootstrap","ecp.utils","ecp.utils.des","ecp.component.dialog","ecp.component.loading",
	'jstree','ecp.service',"qzz.querygrid","datetimepicker","echarts.all"],
	function($,bootstrap,utils,des,dialog,PageLoading,jstree){  

	//console.log(locale);

	/**
	 * 1.安全处理，预防xss脚本攻击
	 */
    //采用escapeAngleBrackets方法进行尖括号转义
    var a = utils.escapeAngleBrackets("<script>");
	console.log("脚本转义后结果："+a);

	/**
	 * 2.常用工具类
	 */	
	 var b = utils.dateIntoChinese(new Date("2014-12-31"));
	 var c = utils.dateIntoChinese(new Date );
	console.log(b,c); 
	var url = "www.baidu.com?a=1";
	console.log(utils.encodeSearch(url)); 

	/**
	 * 3.加解密
	 */
    var str = "ecp.ygsoft.com";
    //doEncrypt加密 
	console.log(des.doEncrypt(str));
    //doEncrypt解密 
	console.log(des.doDecrypt(des.doEncrypt(str))); 

	/**
	 * 4.表单组件
	 */
     $('#datetimepicker').datetimepicker({
         format: 'yyyy-mm-dd',
         autoclose: true,
         todayBtn: true,
         startView: 'month',
         minView:'month',
         maxView:'decade',
         language:  'zh'
     }); 

	var	grid = $("#dataTable").qzzquerygrid({ 
		"height":200,
		"pager":true,
		"colNames":["字段1","字段2","字段3"],   
		"colModels":[   
			{"name":"a"},        
			{"name":"b"}, 
			{"name":"c"}
		]      
	});  	  
	grid.value([{"a":"001","b":"流程分类","c":"5"},
	            {"a":"001001","b":"资金管理","c":"3"},
                {"a":"001002","b":"报销管理","c":"2"},
                {"a":"002","b":"资金流入管理","c":"6"}
            ]);  
	grid.setFocus();
	grid.first(); 			
	grid.setTotalRecord(10); 	
 
	var myChart = echarts.init(document.getElementById("dataChart"));
	var option = "";
option = {
    title: {
        text: '堆叠区域图'
    },
    tooltip : {
        trigger: 'axis'
    },
    legend: {
        data:['邮件营销','联盟广告','视频广告','直接访问','搜索引擎']
    },
    toolbox: {
        feature: {
            saveAsImage: {}
        }
    },
    grid: {
        left: '3%',
        right: '4%',
        bottom: '3%',
        containLabel: true
    },
    xAxis : [
        {
            type : 'category',
            boundaryGap : false,
            data : ['周一','周二','周三','周四','周五','周六','周日']
        }
    ],
    yAxis : [
        {
            type : 'value'
        }
    ],
    series : [
        {
            name:'邮件营销',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[120, 132, 101, 134, 90, 230, 210]
        },
        {
            name:'联盟广告',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[220, 182, 191, 234, 290, 330, 310]
        },
        {
            name:'视频广告',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[150, 232, 201, 154, 190, 330, 410]
        },
        {
            name:'直接访问',
            type:'line',
            stack: '总量',
            areaStyle: {normal: {}},
            data:[320, 332, 301, 334, 390, 330, 320]
        },
        {
            name:'搜索引擎',
            type:'line',
            stack: '总量',
            label: {
                normal: {
                    show: true,
                    position: 'top'
                }
            },
            areaStyle: {normal: {}},
            data:[820, 932, 901, 934, 1290, 1330, 1320]
        }
    ]
};

	myChart.setOption(option);  

     $('#btn').click(function(){
         dialog.show({
             title: '模态窗标题',   //模态窗标题
             content:'模态窗内容', //模态窗内容
             isTip:true,//标准的提示窗口
             showCloseButton:false,  //不显示关闭按钮
             otherButtons:['取消','确定'],  //增加两个按钮
             otherButtonStyles:['btn-default','btn-primary'], //按钮样式,
             clickButton:function(sender, modal, index){
                 if(index == 0){  //取消按钮
                     modal.modal('hide'); //点击取消关闭模态窗
                 }
                 if(index == 1){  //确定按钮
                     //do something else
                 }
             }
         });
     });

	//加载层
	//var p = new PageLoading(); 
	//展示加载层
	//p.show();

     //测试数据
     $('#jstree').jstree({
         core:{
             data: [ { 'id' : '1', 'parent' : '#', 'text' : '广东省' },
                     { 'id' : '2','parent' : '1', 'text' : '深圳市'  },
                     { 'id' : '3','parent' : '1', 'text' : '广州市'  },
                     { 'id' : '4','parent' : '1', 'text' : '珠海市'  },
                     { 'id' : '5','parent' : '#', 'text' : '湖南省'  },
                     { 'id' : '6','parent' : '5', 'text' : '长沙市aa'  },
                     { 'id' : '7','parent' : '5', 'text' : '岳阳市'  },
                     { 'id' : '8','parent' : '5', 'text' : '深圳市'  },
                     { 'id' : '9','parent' : '#', 'text' : '经济特区' },
                     { 'id' : '10','parent' : '9', 'text' : '深圳市'  }
                 ]
         }
     }); 
 
	/*
     var option = {
          idField: 'dxid',
          textField: 'dxmc',
          data :　[
                 {'dxid':1570001113,'dxmc':'大宇物流'},
                 {'dxid':1570001115,'dxmc':'风尖'},
                 {'dxid':1570001114,'dxmc':'威然'},
                 {'dxid':1570001121,'dxmc':'喆大电力'},
                 {'dxid':1570001119,'dxmc':'安徽电力'},
                 {'dxid':1570001118,'dxmc':'江苏电力'},
                 {'dxid':1570001098,'dxmc':'湖北电力'}
              ]
      }
      //渲染通用下拉控件
      $('#combobox').comboBox(option); 
      //获取值
      $('#get').bind('click', function(){
          alert($.toJSON($('#combobox').comboBox(true).value()))
      });
      //设置值
      $('#set').bind('click', function(){
          $('#combobox').comboBox(true).value([
             {'dxid':1570001121,'dxmc':'喆大电力'}    
          ]);
      });
      //置空
      $('#empty').bind('click', function(){
          $('#combobox').comboBox(true).value([]);
      }); 
	  */

});

